$(function () {
  getUserinfo();
  function getUserinfo() {
    $("#login").on("click", function (e) {
      e.preventDefault();
      //   获取用户输入的数据
      let username = $("#username").val();
      let password = $("#password").val();
      $.ajax({
        url: "http://localhost:8080/api/v1/admin/user/login",
        data: { username, password },
        type: "post",
        success: function (res) {
          if (res.code === 200) {
            localStorage.setItem("token", res.token);
            //   页面跳转
            location.href = "index.html";
          } else {
            console.log("失败");
            console.log(res);
          }
        },
      });
    });
  }
});
